{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "02206ed4",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 加载样本数据\n",
    "from sklearn import datasets\n",
    "digits = datasets.load_digits()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "288dea35",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 特征矩阵\n",
    "features = digits.data\n",
    "## 目标向量\n",
    "targets = digits.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d8b1ccdf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.,  0.,  5., 13.,  9.,  1.,  0.,  0.,  0.,  0., 13., 15., 10.,\n",
       "       15.,  5.,  0.,  0.,  3., 15.,  2.,  0., 11.,  8.,  0.,  0.,  4.,\n",
       "       12.,  0.,  0.,  8.,  8.,  0.,  0.,  5.,  8.,  0.,  0.,  9.,  8.,\n",
       "        0.,  0.,  4., 11.,  0.,  1., 12.,  7.,  0.,  0.,  2., 14.,  5.,\n",
       "       10., 12.,  0.,  0.,  0.,  0.,  6., 13., 10.,  0.,  0.,  0.])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 第一个样本\n",
    "features[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1c327edd",
   "metadata": {},
   "outputs": [],
   "source": [
    "## load_boston  503个波士顿房价的观察值    用于研究回归算法\n",
    "## load_iris    150个鸢尾花尺寸的观察值    用于研究分类算法\n",
    "## load_digits  1797个手写数字图片的观察值 用于研究图像分类算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "21737482",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Features: \n",
      " [[-1.33938922 -0.57181673 -0.60329911]\n",
      " [ 0.2424395   0.47298583 -0.68142588]\n",
      " [-0.76353049 -0.48403143 -1.51308726]]\n",
      "Targets:  \n",
      " [-113.90958699  -19.02116162 -186.69622255]\n"
     ]
    }
   ],
   "source": [
    "## 创建仿真数据\n",
    "from sklearn.datasets import make_regression\n",
    "## 线性回归\n",
    "features, targets, coefficients = make_regression(\n",
    "    n_samples=100,\n",
    "    n_features=3,\n",
    "    n_informative=3,  ## 生成目标向量的特征的数量\n",
    "    n_targets=1,\n",
    "    noise=0.0,\n",
    "    coef=True,\n",
    "    random_state=12\n",
    ")\n",
    "## 查看特征矩阵和目标向量\n",
    "print(\"Features: \\n\", features[:3])\n",
    "print(\"Targets:  \\n\", targets[:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "fe4daf27",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Features: \n",
      " [[ 0.8650116   1.54167469 -1.55101106]\n",
      " [-0.81497465 -1.03135759 -0.88566577]\n",
      " [ 0.81944378 -0.82638094 -0.33245719]]\n",
      "Targets:  \n",
      " [1 0 0]\n"
     ]
    }
   ],
   "source": [
    "## 分类\n",
    "from sklearn.datasets import make_classification\n",
    "features, targets = make_classification(\n",
    "    n_samples=100,\n",
    "    n_features=3,\n",
    "    n_informative=3,  ## 生成目标向量的特征的数量\n",
    "    n_redundant=0,\n",
    "    n_classes=2,\n",
    "    weights=[.25, .75],  ## 25%属于类别A  75%属于类别B\n",
    "    random_state=12\n",
    ")\n",
    "## 查看特征矩阵和目标向量\n",
    "print(\"Features: \\n\", features[:3])\n",
    "print(\"Targets:  \\n\", targets[:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "601d3036",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Features: \n",
      " [[ -8.49045141   5.06856188]\n",
      " [-10.31132355   8.18416774]\n",
      " [ -4.50825508   0.35408296]]\n",
      "Targets:  \n",
      " [0 2 1]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWsAAA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0B4KEeqpcEctJOtxcKaWSgJZBlFIqCWiyVkqpJKDJWimlkoAma6WUSgKarJVSKgloslZKqSSgyVoppZLA/wMDnECxFYjdGQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## 聚类\n",
    "from sklearn.datasets import make_blobs\n",
    "features, targets = make_blobs(\n",
    "    n_samples=100,\n",
    "    n_features=2,\n",
    "    centers=3,       ## 要生成多少个聚类\n",
    "    cluster_std=0.5,\n",
    "    shuffle=True,\n",
    "    random_state=12\n",
    ")\n",
    "## 查看特征矩阵和目标向量\n",
    "print(\"Features: \\n\", features[:3])\n",
    "print(\"Targets:  \\n\", targets[:3])\n",
    "## 可视化\n",
    "import matplotlib.pyplot as plt\n",
    "plt.scatter(features[:, 0], features[:, 1], c=targets)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "706cec71",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   integer                  datatime  category\n",
      "0        5  Sun Dec  4 15:40:27 2022         0\n",
      "1        5  Sun Dec  4 15:40:27 2022         1\n"
     ]
    }
   ],
   "source": [
    "## 加载csv文件\n",
    "import pandas as pd\n",
    "csv_path = \"simulated_data.csv\"\n",
    "dataframe = pd.read_csv(csv_path)\n",
    "print(dataframe.head(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c1b60f9b",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 加载excel文件  pd.read_excel(excel_path, sheetname, header)\n",
    "## 加载JSON文件   pd.read_json(json_path, orient=\"columns\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "35048c55",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   ID  NAME  AGE\n",
      "0   0  IKUN   18\n",
      "1   1  YEJX   23\n"
     ]
    }
   ],
   "source": [
    "## 查询SQL数据库\n",
    "from sqlalchemy import create_engine\n",
    "database_connection = create_engine(\"sqlite:///sample.db\")\n",
    "df = pd.read_sql_query(\"SELECT * FROM DATA\", database_connection)\n",
    "print(df.head(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "572a1bcb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
